<?php
/**
 * Created by PhpStorm.
 * User: zjw
 * Date: 2018/3/8
 * Time: 下午4:00
 */
use common\models\CouponCategory;
use yii\grid\GridView;
use yii\helpers\Html;

?>

<div class="article-index">
    <p>
        <?= Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            [
                'attribute' => 'coupon_id',
                'value' => function ($model) {
                    return \common\models\Coupon::findOne($model->coupon_id)->name;
                }
            ],
            'num',
            'min_num',
            'describe',
            [
                'attribute' => 'execute_at',
                'value' => function ($model) {
                    $space = strtotime(date("Y-m-d") . " 00:00:00");
                    return date("H:i:s", $space + $model->execute_at);
                }
            ],
            [
                'attribute' => 'latest_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->latest_at);
                }
            ],
            [
                'attribute' => 'created_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->created_at);
                }
            ],
            [
                'attribute' => 'updated_at',
                'value' => function ($model) {
                    return date("Y-m-d H:i:s", $model->updated_at);
                }
            ],
            ['class' => 'yii\grid\ActionColumn',
                'template' => '{update} {delete} {url}'
            ],
        ],
    ]); ?>
</div>